/**
 * 抓娃娃主业务逻辑
 */
class Start extends eui.Component {
  private sigin_up: eui.Button;//按钮
  private rule: eui.Button;//规则按钮
  private phone_sign: eui.Image;//请使用电话号码登录
  private my_scores: eui.Button;//我的积分
  private grounp: eui.Group;//我的剩余次数

  private NOW_NUMBER = 15; //计时器的时间,秒
	private DELAYED = 1000; //计时器间隔时间，毫秒

  public constructor() {
    super();
    this.skinName = "startSkin";
    //初始化
    this.init();
  }

  //初始化
  private init() {
    this.sigin_up.addEventListener(egret.TouchEvent.TOUCH_TAP, this.touchTap, this);
    this.rule.addEventListener(egret.TouchEvent.TOUCH_TAP, this.ruleTap, this);
    this.creatTimeer();
    this.timer.start();
    console.log(this.invalidateState())
  }

  private timer: egret.Timer;
  private creatTimeer() {
		this.timer = new egret.Timer(this.DELAYED, this.NOW_NUMBER);
		this.timer.addEventListener(egret.TimerEvent.TIMER, this.timerFunc, this);
		// this.timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.timerComFunc, this);
  }
  
  private timerFunc() {
    console.log(333)
  }

  // 按钮点击事件
  private touchTap() {
    // this.authorizeFn(true);
    this.addChild(new Stage())
  }

  //规则按钮
  private ruleTap() {
    this.ruleOpen();
  }


  //授权函数,控制显示隐藏
  private authorizeFn(status: boolean): void {
      this.sigin_up.visible = !status;
      this.my_scores.visible = !status;
      this.grounp.visible = !status;
      this.phone_sign.visible = status;
  }

  //规则
  private ruleOpen() {
		//游戏结束的业务逻辑
		var mask: egret.Shape = new egret.Shape(); //遮罩对象

		mask.graphics.beginFill(0x000000);
		mask.graphics.drawRect(0, 0, this.width, this.height);
		mask.alpha = 0.5;
    mask.graphics.endFill();
		this.addChild(mask);

		var ruleTip = new RuleTip();
		this.addChild(ruleTip);
  }
}